package src.D_WinSock;

import java.net.InetAddress;
import java.net.UnknownHostException;

// 测试IP
public class D01_TestIp {
    public static void main(String[] args) {
        try {
            // 获取本地ip
            System.out.println(InetAddress.getLocalHost());
            System.out.println(InetAddress.getByName("127.0.0.1"));
            System.out.println(InetAddress.getByName("localhost"));
            // 获取网站ip，通过域名查ip
            System.out.println(InetAddress.getByName("www.baidu.com"));
        } catch (UnknownHostException e) {
            throw new RuntimeException(e);
        }
    }
}
